package nongchang.kuaijiecaifu.com.ncapp_android.ui.popup;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebSettings;
import android.webkit.WebView;

import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.ImageView;


import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import nongchang.kuaijiecaifu.com.ncapp_android.R;

public class AddImageDialog extends Dialog {
    @BindView(R.id.img_add1)
    ImageView imgAdd1;
    @BindView(R.id.img_add2)
    ImageView imgAdd2;
    @BindView(R.id.img_add3)
    ImageView imgAdd3;
    @BindView(R.id.btn_cancel)
    Button btnCancel;
    @BindView(R.id.btn_shangchuan)
    Button btnShangchuan;

    public AddImageDialog(Context context) {
        super(context, R.style.Dialog);
        init();
    }

    public interface OnSubmit {
        void onSubmit();
    }

    private OnSubmit onSubmitListener;

    private void init() {
        Window window = this.getWindow();
        window.requestFeature(Window.FEATURE_NO_TITLE);
        window.getDecorView().setPadding(0, 0, 0, 0);
        setContentView(R.layout.item_add_image);
        ButterKnife.bind(this);

        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        //位置设置到底部
        lp.gravity = Gravity.CENTER;
        window.setWindowAnimations(R.style.Dialog_DropDown_PopupAnimation);
        window.setAttributes(lp);

    }

    @OnClick({R.id.btn_cancel, R.id.btn_shangchuan})
    void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_cancel:
                this.dismiss();
                break;
            case R.id.btn_shangchuan:
                if (onSubmitListener != null) {
                    onSubmitListener.onSubmit();
                }
                break;
        }
    }
}